from allpairspy import AllPairs

from api_py.enums.cookie import Cookie
from api_py.generate_case.template import template_case
from api_py.utils.file_sys import write_json

user_id = [
    {"value": "", "description": "访客id为空"},
    {"value": "ff80818184524b50018480d2ce92018a", "description": "存在的用户"},
    {"value": "ff80818184524b50018480d2ce9exist", "description": "但不存在用户"},
    {"value": "invalid_id", "description": "非法userid"},
]

cookies = [
    {"value": Cookie.ADMIN_COOKIE.value, "description": "管理员登录"},
    {"value": Cookie.SUPERVISOR_COOKIE.value, "description": "督导登录"},
    {"value": Cookie.COUNSELOR_COOKIE.value, "description": "咨询师登录"},
    {"value": Cookie.WEIXIN_COOKIE.value, "description": "微信访客登录"},
    {"value": Cookie.NULL_COOKIE.value, "description": "未登录"},
    {"value": Cookie.ERROR_COOKIE.value, "description": "其他Cookie"},
]



def case20_user_active(api_type):
    json_result = {}
    i = 0

    # 检测数据格式的用例
    for id in user_id:
        case = template_case()
        request = case["request"]

        # 包装url参数
        request["params"]["userId"] = id
        # 包装头部信息
        request["headers"]["Cookie"] = cookies[0]

        json_result[i] = case
        i += 1

    # 检查用户权限的用例
    for cookie in cookies:
        case = template_case()
        request = case["request"]

        # 包装url参数
        request["params"]["userId"] = user_id[1]
        # 包装头部信息
        request["headers"]["Cookie"] = cookie

        json_result[i] = case
        i += 1

    write_json(api_type.value[0]["file_name"], json_result)
